<template>
	<view class="poAbs wPer100 hPer100 backCol0a0a0aS5 zIndex999 top0 left0 f24r" @touchmove.stop.prevent>
		<view class="poFixed bom0 left0 wPer100 backColWhite borTLRad26r borTRRad26r overHid pl20r pr20r boSiBorBox">
			<view class="h86r disFlex col999 aliItCenter">
				<view class="flex1">
					<image :src="baseUrl + 'iconHornGreen.png'" mode="aspectFit"
						class="w30r h30r poRel top6r"
					></image>
					<text class="col99c043">
						[{{advanceBookingObj.hour}}小时起订]
					</text>
					选择时间必须连续
				</view>
				<view class="w100r teAliCenter" @click="closeAdvanceBooking">
					<image :src="baseUrl + 'iconCloseBlack.png'" mode="aspectFit"
						class="w40r h40r poRel "
					></image>
				</view>
			</view>
			<scroll-view scroll-x="true" class="whSpaNow backCol2c6739 borRad30r col999">
				<view :class="['disInBlo', 'hPer100', 'borRad30r', 'w170r', 'teAliCenter',
						'pt20r', 'pb20r', appointmentDay == index ? 'colFff backCol99c043' : ''
					]" @click="appointmentSwitch(index)"
					v-for="(item, index) in appointmentAry" :key="index"
				>
					<view class="f26r mb5r foWeiBold">
						{{item.timeNum}}
					</view>
					<view class="">
						{{item.whatDay}}
					</view>
				</view>
			</scroll-view>
			<scroll-view scroll-y="true" class="h700r pt20r pb20r boSiBorBox">
				<view v-for="(item, index) in timeSlotAry" :key="index"
					:class="['disInBlo', 'wPer33S333333', 'mb20r',
					]" v-show="!item.slotBefore"
				>
					<view :class="['borRad10r', 'mAuto', 'ml10r', 'mr10r', 'teAliCenter',
							'pt20r', 'pb20r',
							'boxSha0a5a12a0Rgb217a226a223a50Per',
							item.slotGray || item.slotCleaning ? 'colBcbcbc backColWhite' :
								item.slotCheck ? 'backCol99c043 colFff' : 'backColWhite'
						]"
						@click="cliSlotBtn(index, item.slotCheck, item.slotGray, item.slotCleaning)"
					>
					<!-- item.isInUse ? 'colC72d21 backColWhite' -->
						<view class="mb5r">
							{{item.nextDay ? '次日' : ''}}{{
								item.slotOneBefore ? item.slotNowData.slotBText : item.slotBText
							}} ~ {{item.slotEText}}
						</view>
						<text>
							{{
								item.slotGray ? (item.slotStatus == 1 ? '预约中' :
													item.slotStatus == 2 ? '使用中' :
													item.slotStatus == 3 ? '已完成' :
													item.slotStatus == 4 ? '已取消' : '空闲中') :
								item.slotCleaning ? '待保洁' : '空闲'
							}}
						</text>
					</view>
				</view>
			</scroll-view>
			<view class="pt10r pb10r pl20r pr20r colFff teAliCenter f30r">
				<view class="lh70r borRad35r backImgLiGrTR2c6739a99c043"
					@click="cliAppointmentTime1"
				>
					立即预订
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { dateLimit, numTurnDayToday } from '@/utils/utils.js'
import { getRoomDetailNew, unifiedOrder,
	getMemberCardruleInfo, getTaeRoomDataInfo } from '@/utils/api.js'
import { baseUrl } from '@/utils/request.js'
export default {
	props: {
		advanceBookingObj: {
			type: Object,
			default: {
				topIsWho: { type: Number, default: 0},//上级页面 1为列表 2为房间
				tid: { type: String, default: '' },//茶室id
				rid: { type: String, default: '' },//房间id
				hour: { type: String, default: '' },//起订时长
				setMealType: { type: String, default: '2' },//是否必购套餐 1是 2否
				setMealId: { type: String, default: '' },//sid传套餐id
				setMealMoney: { type: Number, default: 0 },//选择的套餐价格
				cardDiscount: { type: String, default: '' },//会员卡折扣
				originalCost: { type: String, default: '' },//原价/每小时
			},
		},
	},
	data() {
		return {
			baseUrl,
			appointmentAry: [], appointmentDay: 0,
			dateVal1: '',
			colorAry: [],
			timeSlotAry: [],
		}
	},
	mounted() {
		this.appointmentAry = [
			{
				timeNum: dateLimit('', '', true),
				whatDay: '今天',
				specificNum: dateLimit()
			}, {
				timeNum: dateLimit('', new Date(new Date().getTime() + 1 * 24 * 60 * 60 * 1000), true), 
				whatDay: '周' + numTurnDayToday(new Date(new Date().getTime() + 1 * 24 * 60 * 60 * 1000).getDay()),
				specificNum: dateLimit('', new Date(new Date().getTime() + 1 * 24 * 60 * 60 * 1000))
			}, {
				timeNum: dateLimit('', new Date(new Date().getTime() + 2 * 24 * 60 * 60 * 1000), true), 
				whatDay: '周' + numTurnDayToday(new Date(new Date().getTime() + 2 * 24 * 60 * 60 * 1000).getDay()),
				specificNum: dateLimit('', new Date(new Date().getTime() + 2 * 24 * 60 * 60 * 1000))
			}, {
				timeNum: dateLimit('', new Date(new Date().getTime() + 3 * 24 * 60 * 60 * 1000), true), 
				whatDay: '周' + numTurnDayToday(new Date(new Date().getTime() + 3 * 24 * 60 * 60 * 1000).getDay()),
				specificNum: dateLimit('', new Date(new Date().getTime() + 3 * 24 * 60 * 60 * 1000))
			}, {
				timeNum: dateLimit('', new Date(new Date().getTime() + 4 * 24 * 60 * 60 * 1000), true), 
				whatDay: '周' + numTurnDayToday(new Date(new Date().getTime() + 4 * 24 * 60 * 60 * 1000).getDay()),
				specificNum: dateLimit('', new Date(new Date().getTime() + 4 * 24 * 60 * 60 * 1000))
			}, {
				timeNum: dateLimit('', new Date(new Date().getTime() + 5 * 24 * 60 * 60 * 1000), true), 
				whatDay: '周' + numTurnDayToday(new Date(new Date().getTime() + 5 * 24 * 60 * 60 * 1000).getDay()),
				specificNum: dateLimit('', new Date(new Date().getTime() + 5 * 24 * 60 * 60 * 1000))
			}, {
				timeNum: dateLimit('', new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000), true), 
				whatDay: '周' + numTurnDayToday(new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000).getDay()),
				specificNum: dateLimit('', new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000))
			}
		];
		if(this.advanceBookingObj.topIsWho == 2) this.renovateColor();
	},
	methods: {
		getData0() {
			getRoomDetailNew({
				date: this.dateVal1,
				tid: this.advanceBookingObj.tid,
				rid: this.advanceBookingObj.rid
			}).then(res => {
				this.getData1(res.data);
			})
			// this.getData1();
		},
		getData1(res1Data) {
			this.timeSlotAry = [];
			let oneBeforeNum = 0;
			/**
			 * isInUse：true为使用中
			 * 
			 * isRed：进度条颜色，true为彩色、false为白色可预订
			 * isBefore：true为隐藏该选择时间框，false的才显示
			 * isGray：true为已被预订
			 * isCleaning：true为已预订时间的后保洁时间
			 * isOneBefore：true为是今天且有显示选择时间框的第一个，false为不是
			 */
			this.colorAry = [
				{timeBText: '00:00', timeEText: '00:30', timeBVal: 0, timeEVal: 0.5},
				{timeBText: '00:30', timeEText: '01:00', timeBVal: 0.5, timeEVal: 1},
				{timeBText: '01:00', timeEText: '01:30', timeBVal: 1, timeEVal: 1.5},
				{timeBText: '01:30', timeEText: '02:00', timeBVal: 1.5, timeEVal: 2},
				{timeBText: '02:00', timeEText: '02:30', timeBVal: 2, timeEVal: 2.5},
				{timeBText: '02:30', timeEText: '03:00', timeBVal: 2.5, timeEVal: 3},
				{timeBText: '03:00', timeEText: '03:30', timeBVal: 3, timeEVal: 3.5},
				{timeBText: '03:30', timeEText: '04:00', timeBVal: 3.5, timeEVal: 4},
				{timeBText: '04:00', timeEText: '04:30', timeBVal: 4, timeEVal: 4.5},
				{timeBText: '04:30', timeEText: '05:00', timeBVal: 4.5, timeEVal: 5},
				{timeBText: '05:00', timeEText: '05:30', timeBVal: 5, timeEVal: 5.5},
				{timeBText: '05:30', timeEText: '06:00', timeBVal: 5.5, timeEVal: 6},
				{timeBText: '06:00', timeEText: '06:30', timeBVal: 6, timeEVal: 6.5},
				{timeBText: '06:30', timeEText: '07:00', timeBVal: 6.5, timeEVal: 7},
				{timeBText: '07:00', timeEText: '07:30', timeBVal: 7, timeEVal: 7.5},
				{timeBText: '07:30', timeEText: '08:00', timeBVal: 7.5, timeEVal: 8},
				{timeBText: '08:00', timeEText: '08:30', timeBVal: 8, timeEVal: 8.5},
				{timeBText: '08:30', timeEText: '09:00', timeBVal: 8.5, timeEVal: 9},
				{timeBText: '09:00', timeEText: '09:30', timeBVal: 9, timeEVal: 9.5},
				{timeBText: '09:30', timeEText: '10:00', timeBVal: 9.5, timeEVal: 10},
				{timeBText: '10:00', timeEText: '10:30', timeBVal: 10, timeEVal: 10.5},
				{timeBText: '10:30', timeEText: '11:00', timeBVal: 10.5, timeEVal: 11},
				{timeBText: '11:00', timeEText: '11:30', timeBVal: 11, timeEVal: 11.5},
				{timeBText: '11:30', timeEText: '12:00', timeBVal: 11.5, timeEVal: 12},
				{timeBText: '12:00', timeEText: '12:30', timeBVal: 12, timeEVal: 12.5},
				{timeBText: '12:30', timeEText: '13:00', timeBVal: 12.5, timeEVal: 13},
				{timeBText: '13:00', timeEText: '13:30', timeBVal: 13, timeEVal: 13.5},
				{timeBText: '13:30', timeEText: '14:00', timeBVal: 13.5, timeEVal: 14},
				{timeBText: '14:00', timeEText: '14:30', timeBVal: 14, timeEVal: 14.5},
				{timeBText: '14:30', timeEText: '15:00', timeBVal: 14.5, timeEVal: 15},
				{timeBText: '15:00', timeEText: '15:30', timeBVal: 15, timeEVal: 15.5},
				{timeBText: '15:30', timeEText: '16:00', timeBVal: 15.5, timeEVal: 16},
				{timeBText: '16:00', timeEText: '16:30', timeBVal: 16, timeEVal: 16.5},
				{timeBText: '16:30', timeEText: '17:00', timeBVal: 16.5, timeEVal: 17},
				{timeBText: '17:00', timeEText: '17:30', timeBVal: 17, timeEVal: 17.5},
				{timeBText: '17:30', timeEText: '18:00', timeBVal: 17.5, timeEVal: 18},
				{timeBText: '18:00', timeEText: '18:30', timeBVal: 18, timeEVal: 18.5},
				{timeBText: '18:30', timeEText: '19:00', timeBVal: 18.5, timeEVal: 19},
				{timeBText: '19:00', timeEText: '19:30', timeBVal: 19, timeEVal: 19.5},
				{timeBText: '19:30', timeEText: '20:00', timeBVal: 19.5, timeEVal: 20},
				{timeBText: '20:00', timeEText: '20:30', timeBVal: 20, timeEVal: 20.5},
				{timeBText: '20:30', timeEText: '21:00', timeBVal: 20.5, timeEVal: 21},
				{timeBText: '21:00', timeEText: '21:30', timeBVal: 21, timeEVal: 21.5},
				{timeBText: '21:30', timeEText: '22:00', timeBVal: 21.5, timeEVal: 22},
				{timeBText: '22:00', timeEText: '22:30', timeBVal: 22, timeEVal: 22.5},
				{timeBText: '22:30', timeEText: '23:00', timeBVal: 22.5, timeEVal: 23},
				{timeBText: '23:00', timeEText: '23:30', timeBVal: 23, timeEVal: 23.5},
				{timeBText: '23:30', timeEText: '24:00', timeBVal: 23.5, timeEVal: 24}
				// ,{timeBText: '24:00', timeEText: '0:00', timeBVal: 24, timeEVal: 0}
			];
			this.colorAry.forEach(item1 => {
				if(item1.timeBVal < (new Date().getHours() + (new Date().getMinutes() / 60)) && this.dateVal1 == dateLimit()) {
					item1.isRed = true;
				}else {
					item1.isRed = false;
				}
				item1.isGray = false;
				item1.isCleaning = false;
				// // item1.isInUse = false;
				if(item1.timeBVal < (new Date().getHours() + (new Date().getMinutes() / 60) - 0.5) && this.dateVal1 == dateLimit()) {
					item1.isBefore = true;
				}else {
					if((new Date().getHours() + (new Date().getMinutes() / 60) - 0.5) == item1.timeBVal) {
						item1.isBefore = true;
					}else {
						item1.isBefore = false;
						if(oneBeforeNum === 0 && this.dateVal1 == dateLimit()) {
							oneBeforeNum = item1;
							item1.isOneBefore = true;
							item1.isNowData = {
								slotBText: ((new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()) + ':' + (new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes())),
								slotBVal: new Date().getHours() + new Date().getMinutes() / 60
							};
						}
					}
				}
			})
			if(res1Data && res1Data.end_date_arr && res1Data.end_date_arr.length) {
				let isBeAry2 = [];
				res1Data.end_date_arr.forEach(item1 => {
					item1.start_time = item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.start_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.start_time.replace(/T/g,' ').replace(/-/g,"/");
					item1.end_time = item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.end_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.end_time.replace(/T/g,' ').replace(/-/g,"/");
					let isAddAry = false;
					if(((new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60) % 0.5 != 0) || ((new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) % 0.5 != 0)) {
						isAddAry = true;
					}
					isBeAry2.push({
						make_status: item1.make_status,
						isAddAry,
						isB2BVal: (dateLimit('', new Date(item1.start_time)) == this.dateVal1 ? (new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60) : 0),
						isB2EVal: (dateLimit('', new Date(item1.end_time)) == this.dateVal1 ? (new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) : 24),
						isB2BText: (new Date(item1.start_time).getHours() < 10 ? '0' + new Date(item1.start_time).getHours() : new Date(item1.start_time).getHours()) + ':' + (new Date(item1.start_time).getMinutes() < 10 ? '0' + new Date(item1.start_time).getMinutes() : new Date(item1.start_time).getMinutes()),
						isB2EText: (new Date(item1.end_time).getHours() < 10 ? '0' + new Date(item1.end_time).getHours() : new Date(item1.end_time).getHours()) + ':' + (new Date(item1.end_time).getMinutes() < 10 ? '0' + new Date(item1.end_time).getMinutes() : new Date(item1.end_time).getMinutes())
					})
				})
				isBeAry2.forEach(item1 => {
					this.colorAry.forEach((item2, index2) => {
						if(item1.isB2BVal == 0 && item1.isB2EVal == 0) {//昨天是预订到24点
							if(item2.timeBVal == 0 && item2.timeEVal == 0.5) {//挑第一个时间框
								console.log('当天-出现这个表示昨天是预订到24点', item1)
								item2.isRed = true;
								item2.isCleaning = true;
							}
						}
						if(item1.isAddAry == true && item1.isB2BVal < item2.timeEVal && item1.isB2BVal > item2.timeBVal) {
							item2.isCleaning = false;
							item2.isGray = true;
							item2.isRed = true;
							item2.timeBText = item1.isB2BText;
							item2.timeBVal = item1.isB2BVal;
							if(index2 != 0) {
								this.colorAry[index2 - 1].timeEText = item1.isB2BText;
								this.colorAry[index2 - 1].timeEVal = item1.isB2BVal;
								this.colorAry[index2 - 1].timeBText = ((Math.trunc(item1.isB2BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB2BVal - 0.5) : Math.trunc(item1.isB2BVal - 0.5)) + ':' + ((Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100)));
								this.colorAry[index2 - 1].timeBVal = item1.isB2BVal - 0.5;
								if(index2 != 1) {
									this.colorAry[index2 - 2].timeEText = ((Math.trunc(item1.isB2BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB2BVal - 0.5) : Math.trunc(item1.isB2BVal - 0.5)) + ':' + ((Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100)));
									this.colorAry[index2 - 2].timeEVal = item1.isB2BVal - 0.5;
								}
							}
						}
						if(item1.isAddAry == true && item1.isB2EVal < item2.timeEVal && item1.isB2EVal > item2.timeBVal) {
							item2.isCleaning = true;
							item2.isGray = false;
							item2.isRed = true;
							item2.timeBText = item1.isB2EText;
							item2.timeBVal = item1.isB2EVal;
							item2.timeEText = ((Math.trunc(item1.isB2EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB2EVal + 0.5) : Math.trunc(item1.isB2EVal + 0.5)) + ':' + ((Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100)));
							item2.timeEVal = item1.isB2EVal + 0.5;
							if(index2 != 0) {
								this.colorAry[index2 - 1].timeEText = item1.isB2EText;
								this.colorAry[index2 - 1].timeEVal = item1.isB2EVal;
							}
							if(index2 != (this.colorAry.length - 1)) {
								this.colorAry[index2 + 1].timeBText = ((Math.trunc(item1.isB2EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB2EVal + 0.5) : Math.trunc(item1.isB2EVal + 0.5)) + ':' + ((Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100)));
								this.colorAry[index2 + 1].timeBVal = item1.isB2EVal + 0.5;
								this.colorAry[index2 + 1].timeEText = ((Math.trunc(item1.isB2EVal + 1) < 10 ? '0' + Math.trunc(item1.isB2EVal + 1) : Math.trunc(item1.isB2EVal + 1)) + ':' + ((Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) : (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100)));
								this.colorAry[index2 + 1].timeEVal = item1.isB2EVal + 1;
								if((index2 + 1) != (this.colorAry.length - 1)) {
									this.colorAry[index2 + 2].timeBText = ((Math.trunc(item1.isB2EVal + 1) < 10 ? '0' + Math.trunc(item1.isB2EVal + 1) : Math.trunc(item1.isB2EVal + 1)) + ':' + ((Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) : (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100)));
									this.colorAry[index2 + 2].timeBVal = item1.isB2EVal + 1;
								}
							}
						}
						if(item2.timeEVal > item1.isB2BVal && item1.isB2EVal > item2.timeBVal) {
							item2.make_status = item1.make_status;
							item2.isGray = true;
							item2.isCleaning = false;
							if(index2 != (this.colorAry.length -1)) {
								this.colorAry[index2 + 1].isRed = true;
								this.colorAry[index2 + 1].isCleaning = true;
							}
						}
					})
				})
			}
			if(res1Data && res1Data.start_date_arr && res1Data.start_date_arr.length) {
				let isBeAry1 = [];
				res1Data.start_date_arr.forEach(item1 => {
					item1.start_time = item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.start_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.start_time.replace(/T/g,' ').replace(/-/g,"/");
					item1.end_time = item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.end_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.end_time.replace(/T/g,' ').replace(/-/g,"/");
					let isAddAry = false;
					if(((new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60) % 0.5 != 0) || ((new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) % 0.5 != 0)) {
						isAddAry = true;
					}
					isBeAry1.push({
						make_status: item1.make_status,
						isAddAry,
						isB1BVal: (new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60),
						isB1EVal: (dateLimit('', new Date(item1.end_time)) == this.dateVal1 ? (new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) : 24),
						isB1BText: (new Date(item1.start_time).getHours() < 10 ? '0' + new Date(item1.start_time).getHours() : new Date(item1.start_time).getHours()) + ':' + (new Date(item1.start_time).getMinutes() < 10 ? '0' + new Date(item1.start_time).getMinutes() : new Date(item1.start_time).getMinutes()),
						isB1EText: (new Date(item1.end_time).getHours() < 10 ? '0' + new Date(item1.end_time).getHours() : new Date(item1.end_time).getHours()) + ':' + (new Date(item1.end_time).getMinutes() < 10 ? '0' + new Date(item1.end_time).getMinutes() : new Date(item1.end_time).getMinutes())
					})
				})
				isBeAry1.forEach(item1 => {
					this.colorAry.forEach((item2, index2) => {
						if(item1.isAddAry == true && item1.isB1BVal < item2.timeEVal && item1.isB1BVal > item2.timeBVal) {
							item2.isCleaning = false;
							item2.isGray = true;
							item2.isRed = true;
							item2.timeBText = item1.isB1BText;
							item2.timeBVal = item1.isB1BVal;
							if(index2 != 0) {
								this.colorAry[index2 - 1].timeEText = item1.isB1BText;
								this.colorAry[index2 - 1].timeEVal = item1.isB1BVal;
								this.colorAry[index2 - 1].timeBText = ((Math.trunc(item1.isB1BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB1BVal - 0.5) : Math.trunc(item1.isB1BVal - 0.5)) + ':' + ((Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100)));
								this.colorAry[index2 - 1].timeBVal = item1.isB1BVal - 0.5;
								if(index2 != 1) {
									this.colorAry[index2 - 2].timeEText = ((Math.trunc(item1.isB1BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB1BVal - 0.5) : Math.trunc(item1.isB1BVal - 0.5)) + ':' + ((Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100)));
									this.colorAry[index2 - 2].timeEVal = item1.isB1BVal - 0.5;
								}
							}
						}
						if(item1.isAddAry == true && item1.isB1EVal < item2.timeEVal && item1.isB1EVal > item2.timeBVal) {
							item2.isCleaning = true;
							item2.isGray = false;
							item2.isRed = true;
							item2.timeBText = item1.isB1EText;
							item2.timeBVal = item1.isB1EVal;
							item2.timeEText = ((Math.trunc(item1.isB1EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB1EVal + 0.5) : Math.trunc(item1.isB1EVal + 0.5)) + ':' + ((Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100)));
							item2.timeEVal = item1.isB1EVal + 0.5;
							if(index2 != 0) {
								this.colorAry[index2 - 1].timeEText = item1.isB1EText;
								this.colorAry[index2 - 1].timeEVal = item1.isB1EVal;
							}
							if(index2 != (this.colorAry.length - 1)) {
								this.colorAry[index2 + 1].timeBText = ((Math.trunc(item1.isB1EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB1EVal + 0.5) : Math.trunc(item1.isB1EVal + 0.5)) + ':' + ((Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100)));
								this.colorAry[index2 + 1].timeBVal = item1.isB1EVal + 0.5;
								this.colorAry[index2 + 1].timeEText = ((Math.trunc(item1.isB1EVal + 1) < 10 ? '0' + Math.trunc(item1.isB1EVal + 1) : Math.trunc(item1.isB1EVal + 1)) + ':' + ((Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) : (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100)));
								this.colorAry[index2 + 1].timeEVal = item1.isB1EVal + 1;
								if((index2 + 1) != (this.colorAry.length - 1)) {
									this.colorAry[index2 + 2].timeBText = ((Math.trunc(item1.isB1EVal + 1) < 10 ? '0' + Math.trunc(item1.isB1EVal + 1) : Math.trunc(item1.isB1EVal + 1)) + ':' + ((Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) : (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100)));
									this.colorAry[index2 + 2].timeBVal = item1.isB1EVal + 1;
								}
							}
						}
						if(item2.timeEVal > item1.isB1BVal && item1.isB1EVal > item2.timeBVal) {//优化写法
							item2.make_status = item1.make_status;
							item2.isRed = true;
							item2.isGray = true;
							item2.isCleaning = false;
							if(index2 != (this.colorAry.length - 1)) {
								this.colorAry[index2 + 1].isRed = true;
								this.colorAry[index2 + 1].isCleaning = true;
							}
						}
						if(item2.isOneBefore) {
							if(index2 != 0 && this.colorAry[index2 - 1].isCleaning && item2.isGray == false) {//处理“现在时间”为上一单的“保洁时间”当中，会异常显示从“现在时间”可以预约
								item2.isCleaning = true;
								item2.timeEText = this.colorAry[index2 - 1].timeEText;
								item2.timeEVal = this.colorAry[index2 - 1].timeEVal;
								if(index2 != (this.colorAry.length - 1)) {
									this.colorAry[index2 + 1].timeBText = this.colorAry[index2 - 1].timeEText;
									this.colorAry[index2 + 1].timeBVal = this.colorAry[index2 - 1].timeEVal;
								}
							}
							// if(index2 != 0) {//因为上方的判断会出现“现在时间”处于“续单”当中时，第一个框文字为“待保洁”
							//但这段会导致“现在时间”“使用中”时，会变为“空闲”
							// 	item2.make_status = this.colorAry[index2 - 1].make_status;
							// 	item2.isCleaning = this.colorAry[index2 - 1].isCleaning;
							// 	item2.isGray = this.colorAry[index2 - 1].isGray;
							// 	item2.timeEText = this.colorAry[index2 - 1].timeEText;
							// 	item2.timeEVal = this.colorAry[index2 - 1].timeEVal;
							// 	if(index2 != (this.colorAry.length - 1)) {
							// 		this.colorAry[index2 + 1].timeBText = this.colorAry[index2 - 1].timeEText;
							// 		this.colorAry[index2 + 1].timeBVal = this.colorAry[index2 - 1].timeEVal;
							// 	}
							// 	console.log(11, item2)
							// }
						}
					})
				})
			}
			// console.log(11, this.colorAry)
			this.$emit('changeColor', this.colorAry);
			this.colorAry.forEach(item1 => {
				this.timeSlotAry.push({
					nextDay: false,
					slotBText: item1.timeBText,
					slotEText: item1.timeEText,
					slotBefore: item1.isBefore,
					slotCheck: false,
					slotBVal: item1.timeBVal,
					slotEVal: item1.timeEVal,
					slotGray: item1.isGray,
					slotCleaning: item1.isCleaning,
					slotYTD: this.dateVal1,
					slotOneBefore: item1.isOneBefore,
					slotNowData: item1.isNowData,
					slotStatus: item1.make_status
				})
			})
			getRoomDetailNew({
				date: (dateLimit('', new Date(new Date(this.dateVal1).getTime() + 24 * 60 * 60 * 1000))),
				tid: this.advanceBookingObj.tid,
				rid: this.advanceBookingObj.rid
			}).then(res => {
				this.getData2(res.data, dateLimit('', new Date(new Date(this.dateVal1).getTime() + 24 * 60 * 60 * 1000)));
			})
		},
		getData2(res1Data, dateTwo) {
			let tomorrowAry = [
				{timeBText: '00:00', timeEText: '00:30', timeBVal: 0, timeEVal: 0.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '00:30', timeEText: '01:00', timeBVal: 0.5, timeEVal: 1, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '01:00', timeEText: '01:30', timeBVal: 1, timeEVal: 1.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '01:30', timeEText: '02:00', timeBVal: 1.5, timeEVal: 2, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '02:00', timeEText: '02:30', timeBVal: 2, timeEVal: 2.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '02:30', timeEText: '03:00', timeBVal: 2.5, timeEVal: 3, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '03:00', timeEText: '03:30', timeBVal: 3, timeEVal: 3.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '03:30', timeEText: '04:00', timeBVal: 3.5, timeEVal: 4, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '04:00', timeEText: '04:30', timeBVal: 4, timeEVal: 4.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '04:30', timeEText: '05:00', timeBVal: 4.5, timeEVal: 5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '05:00', timeEText: '05:30', timeBVal: 5, timeEVal: 5.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '05:30', timeEText: '06:00', timeBVal: 5.5, timeEVal: 6, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '06:00', timeEText: '06:30', timeBVal: 6, timeEVal: 6.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '06:30', timeEText: '07:00', timeBVal: 6.5, timeEVal: 7, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '07:00', timeEText: '07:30', timeBVal: 7, timeEVal: 7.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '07:30', timeEText: '08:00', timeBVal: 7.5, timeEVal: 8, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '08:00', timeEText: '08:30', timeBVal: 8, timeEVal: 8.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '08:30', timeEText: '09:00', timeBVal: 8.5, timeEVal: 9, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '09:00', timeEText: '09:30', timeBVal: 9, timeEVal: 9.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '09:30', timeEText: '10:00', timeBVal: 9.5, timeEVal: 10, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '10:00', timeEText: '10:30', timeBVal: 10, timeEVal: 10.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '10:30', timeEText: '11:00', timeBVal: 10.5, timeEVal: 11, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '11:00', timeEText: '11:30', timeBVal: 11, timeEVal: 11.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '11:30', timeEText: '12:00', timeBVal: 11.5, timeEVal: 12, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '12:00', timeEText: '12:30', timeBVal: 12, timeEVal: 12.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '12:30', timeEText: '13:00', timeBVal: 12.5, timeEVal: 13, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '13:00', timeEText: '13:30', timeBVal: 13, timeEVal: 13.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '13:30', timeEText: '14:00', timeBVal: 13.5, timeEVal: 14, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '14:00', timeEText: '14:30', timeBVal: 14, timeEVal: 14.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '14:30', timeEText: '15:00', timeBVal: 14.5, timeEVal: 15, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '15:00', timeEText: '15:30', timeBVal: 15, timeEVal: 15.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '15:30', timeEText: '16:00', timeBVal: 15.5, timeEVal: 16, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '16:00', timeEText: '16:30', timeBVal: 16, timeEVal: 16.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '16:30', timeEText: '17:00', timeBVal: 16.5, timeEVal: 17, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '17:00', timeEText: '17:30', timeBVal: 17, timeEVal: 17.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '17:30', timeEText: '18:00', timeBVal: 17.5, timeEVal: 18, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '18:00', timeEText: '18:30', timeBVal: 18, timeEVal: 18.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '18:30', timeEText: '19:00', timeBVal: 18.5, timeEVal: 19, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '19:00', timeEText: '19:30', timeBVal: 19, timeEVal: 19.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '19:30', timeEText: '20:00', timeBVal: 19.5, timeEVal: 20, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '20:00', timeEText: '20:30', timeBVal: 20, timeEVal: 20.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '20:30', timeEText: '21:00', timeBVal: 20.5, timeEVal: 21, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '21:00', timeEText: '21:30', timeBVal: 21, timeEVal: 21.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '21:30', timeEText: '22:00', timeBVal: 21.5, timeEVal: 22, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '22:00', timeEText: '22:30', timeBVal: 22, timeEVal: 22.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '22:30', timeEText: '23:00', timeBVal: 22.5, timeEVal: 23, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '23:00', timeEText: '23:30', timeBVal: 23, timeEVal: 23.5, isBefore: false, isGray: false, isCleaning: false},
				{timeBText: '23:30', timeEText: '24:00', timeBVal: 23.5, timeEVal: 24, isBefore: false, isGray: false, isCleaning: false}
			];
			/**
			 * start_date_arr：被当成今天无论是否跨天选中 - date: 2023-02-22: {start_time: "2023-02-22 23:30:00", end_time: "2023-02-23 00:30:00"}
			 * end_date_arr：被当成次日且跨天选中 - date: 2023-02-23: {start_time: "2023-02-22 23:30:00", end_time: "2023-02-23 00:30:00"}
			 */
			if(res1Data && res1Data.end_date_arr && res1Data.end_date_arr.length) {
				let isBeAry2 = [];
				res1Data.end_date_arr.forEach(item1 => {
					item1.start_time = item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.start_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.start_time.replace(/T/g,' ').replace(/-/g,"/");
					item1.end_time = item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.end_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.end_time.replace(/T/g,' ').replace(/-/g,"/");
					let isAddAry = false;
					if(((new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60) % 0.5 != 0) || ((new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) % 0.5 != 0)) {
						isAddAry = true;
					}
					isBeAry2.push({
						make_status: item1.make_status,
						isAddAry,
						isB2BVal: (dateLimit('', new Date(item1.start_time)) == dateTwo ? (new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60) : 0),
						isB2EVal: (dateLimit('', new Date(item1.end_time)) == dateTwo ? (new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) : 24),
						isB2BText: (new Date(item1.start_time).getHours() < 10 ? '0' + new Date(item1.start_time).getHours() : new Date(item1.start_time).getHours()) + ':' + (new Date(item1.start_time).getMinutes() < 10 ? '0' + new Date(item1.start_time).getMinutes() : new Date(item1.start_time).getMinutes()),
						isB2EText: (new Date(item1.end_time).getHours() < 10 ? '0' + new Date(item1.end_time).getHours() : new Date(item1.end_time).getHours()) + ':' + (new Date(item1.end_time).getMinutes() < 10 ? '0' + new Date(item1.end_time).getMinutes() : new Date(item1.end_time).getMinutes())
					})
				})
				isBeAry2.forEach(item1 => {
					tomorrowAry.forEach((item2, index2) => {
						if(item1.isB2BVal == 0 && item1.isB2EVal == 0) {//昨天是预订到24点
							if(item2.timeBVal == 0 && item2.timeEVal == 0.5) {//挑第一个时间框
								console.log('次日-出现这个表示昨天是预订到24点', item1)
								item2.isCleaning = true;
							}
						}
						if(item1.isAddAry == true && item1.isB2BVal < item2.timeEVal && item1.isB2BVal > item2.timeBVal) {
							item2.isCleaning = false;
							item2.isGray = true;
							// item2.isRed = true;
							item2.timeBText = item1.isB2BText;
							item2.timeBVal = item1.isB2BVal;
							if(index2 != 0) {
								tomorrowAry[index2 - 1].timeEText = item1.isB2BText;
								tomorrowAry[index2 - 1].timeEVal = item1.isB2BVal;
								tomorrowAry[index2 - 1].timeBText = ((Math.trunc(item1.isB2BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB2BVal - 0.5) : Math.trunc(item1.isB2BVal - 0.5)) + ':' + ((Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100)));
								tomorrowAry[index2 - 1].timeBVal = item1.isB2BVal - 0.5;
								if(index2 != 1) {
									tomorrowAry[index2 - 2].timeEText = ((Math.trunc(item1.isB2BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB2BVal - 0.5) : Math.trunc(item1.isB2BVal - 0.5)) + ':' + ((Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB2BVal - 0.5 - Math.trunc(item1.isB2BVal - 0.5)) * 60)*100/100)));
									tomorrowAry[index2 - 2].timeEVal = item1.isB2BVal - 0.5;
								}
							}
						}
						if(item1.isAddAry == true && item1.isB2EVal < item2.timeEVal && item1.isB2EVal > item2.timeBVal) {
							item2.isCleaning = true;
							item2.isGray = false;
							// item2.isRed = true;
							item2.timeBText = item1.isB2EText;
							item2.timeBVal = item1.isB2EVal;
							item2.timeEText = ((Math.trunc(item1.isB2EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB2EVal + 0.5) : Math.trunc(item1.isB2EVal + 0.5)) + ':' + ((Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100)));
							item2.timeEVal = item1.isB2EVal + 0.5;
							if(index2 != 0) {
								tomorrowAry[index2 - 1].timeEText = item1.isB2EText;
								tomorrowAry[index2 - 1].timeEVal = item1.isB2EVal;
							}
							if(index2 != (tomorrowAry.length - 1)) {
								tomorrowAry[index2 + 1].timeBText = ((Math.trunc(item1.isB2EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB2EVal + 0.5) : Math.trunc(item1.isB2EVal + 0.5)) + ':' + ((Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB2EVal + 0.5 - Math.trunc(item1.isB2EVal + 0.5)) * 60)*100/100)));
								tomorrowAry[index2 + 1].timeBVal = item1.isB2EVal + 0.5;
								tomorrowAry[index2 + 1].timeEText = ((Math.trunc(item1.isB2EVal + 1) < 10 ? '0' + Math.trunc(item1.isB2EVal + 1) : Math.trunc(item1.isB2EVal + 1)) + ':' + ((Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) : (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100)));
								tomorrowAry[index2 + 1].timeEVal = item1.isB2EVal + 1;
								if((index2 + 1) != (tomorrowAry.length - 1)) {
									tomorrowAry[index2 + 2].timeBText = ((Math.trunc(item1.isB2EVal + 1) < 10 ? '0' + Math.trunc(item1.isB2EVal + 1) : Math.trunc(item1.isB2EVal + 1)) + ':' + ((Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100) : (Math.round((item1.isB2EVal + 1 - Math.trunc(item1.isB2EVal + 1)) * 60)*100/100)));
									tomorrowAry[index2 + 2].timeBVal = item1.isB2EVal + 1;
								}
							}
						}
						if(item2.timeEVal > item1.isB2BVal && item1.isB2EVal > item2.timeBVal) {
							item2.make_status = item1.make_status;
							item2.isGray = true;
							item2.isCleaning = false;
							if(index2 != (tomorrowAry.length -1)) {
								tomorrowAry[index2 + 1].isCleaning = true;
							}
						}
					})
				})
			}
			if(res1Data && res1Data.start_date_arr && res1Data.start_date_arr.length) {
				let isBeAry1 = [];
				res1Data.start_date_arr.forEach(item1 => {
					item1.start_time = item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.start_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.start_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.start_time.replace(/T/g,' ').replace(/-/g,"/");
					item1.end_time = item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')>-1?item1.end_time.replace(/T/g,' ').replace(/-/g,"/").substring(0,item1.end_time.replace(/T/g,' ').replace(/-/g,"/").indexOf('.')):item1.end_time.replace(/T/g,' ').replace(/-/g,"/");
					let isAddAry = false;
					if(((new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60) % 0.5 != 0) || ((new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) % 0.5 != 0)) {
						isAddAry = true;
					}
					isBeAry1.push({
						make_status: item1.make_status,
						isAddAry,
						isB1BVal: (new Date(item1.start_time).getHours() + new Date(item1.start_time).getMinutes() / 60),
						isB1EVal: (dateLimit('', new Date(item1.end_time)) == dateTwo ? (new Date(item1.end_time).getHours() + new Date(item1.end_time).getMinutes() / 60) : 24),
						isB1BText: (new Date(item1.start_time).getHours() < 10 ? '0' + new Date(item1.start_time).getHours() : new Date(item1.start_time).getHours()) + ':' + (new Date(item1.start_time).getMinutes() < 10 ? '0' + new Date(item1.start_time).getMinutes() : new Date(item1.start_time).getMinutes()),
						isB1EText: (new Date(item1.end_time).getHours() < 10 ? '0' + new Date(item1.end_time).getHours() : new Date(item1.end_time).getHours()) + ':' + (new Date(item1.end_time).getMinutes() < 10 ? '0' + new Date(item1.end_time).getMinutes() : new Date(item1.end_time).getMinutes())
					})
				})
				isBeAry1.forEach(item1 => {
					tomorrowAry.forEach((item2, index2) => {
						if(item1.isAddAry == true && item1.isB1BVal < item2.timeEVal && item1.isB1BVal > item2.timeBVal) {
							item2.isCleaning = false;
							item2.isGray = true;
							// item2.isRed = true;
							item2.timeBText = item1.isB1BText;
							item2.timeBVal = item1.isB1BVal;
							if(index2 != 0) {
								tomorrowAry[index2 - 1].timeEText = item1.isB1BText;
								tomorrowAry[index2 - 1].timeEVal = item1.isB1BVal;
								tomorrowAry[index2 - 1].timeBText = ((Math.trunc(item1.isB1BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB1BVal - 0.5) : Math.trunc(item1.isB1BVal - 0.5)) + ':' + ((Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100)));
								tomorrowAry[index2 - 1].timeBVal = item1.isB1BVal - 0.5;
								if(index2 != 1) {
									tomorrowAry[index2 - 2].timeEText = ((Math.trunc(item1.isB1BVal - 0.5) < 10 ? '0' + Math.trunc(item1.isB1BVal - 0.5) : Math.trunc(item1.isB1BVal - 0.5)) + ':' + ((Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100) : (Math.round((item1.isB1BVal - 0.5 - Math.trunc(item1.isB1BVal - 0.5)) * 60)*100/100)));
									tomorrowAry[index2 - 2].timeEVal = item1.isB1BVal - 0.5;
								}
							}
						}
						if(item1.isAddAry == true && item1.isB1EVal < item2.timeEVal && item1.isB1EVal > item2.timeBVal) {
							item2.isCleaning = true;
							item2.isGray = false;
							// item2.isRed = true;
							item2.timeBText = item1.isB1EText;
							item2.timeBVal = item1.isB1EVal;
							item2.timeEText = ((Math.trunc(item1.isB1EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB1EVal + 0.5) : Math.trunc(item1.isB1EVal + 0.5)) + ':' + ((Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100)));
							item2.timeEVal = item1.isB1EVal + 0.5;
							if(index2 != 0) {
								tomorrowAry[index2 - 1].timeEText = item1.isB1EText;
								tomorrowAry[index2 - 1].timeEVal = item1.isB1EVal;
							}
							if(index2 != (tomorrowAry.length - 1)) {
								tomorrowAry[index2 + 1].timeBText = ((Math.trunc(item1.isB1EVal + 0.5) < 10 ? '0' + Math.trunc(item1.isB1EVal + 0.5) : Math.trunc(item1.isB1EVal + 0.5)) + ':' + ((Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100) : (Math.round((item1.isB1EVal + 0.5 - Math.trunc(item1.isB1EVal + 0.5)) * 60)*100/100)));
								tomorrowAry[index2 + 1].timeBVal = item1.isB1EVal + 0.5;
								tomorrowAry[index2 + 1].timeEText = ((Math.trunc(item1.isB1EVal + 1) < 10 ? '0' + Math.trunc(item1.isB1EVal + 1) : Math.trunc(item1.isB1EVal + 1)) + ':' + ((Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) : (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100)));
								tomorrowAry[index2 + 1].timeEVal = item1.isB1EVal + 1;
								if((index2 + 1) != (tomorrowAry.length - 1)) {
									tomorrowAry[index2 + 2].timeBText = ((Math.trunc(item1.isB1EVal + 1) < 10 ? '0' + Math.trunc(item1.isB1EVal + 1) : Math.trunc(item1.isB1EVal + 1)) + ':' + ((Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) < 10 ? '0' + (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100) : (Math.round((item1.isB1EVal + 1 - Math.trunc(item1.isB1EVal + 1)) * 60)*100/100)));
									tomorrowAry[index2 + 2].timeBVal = item1.isB1EVal + 1;
								}
							}
						}
						if(item2.timeEVal > item1.isB1BVal && item1.isB1EVal > item2.timeBVal) {
							item2.make_status = item1.make_status;
							item2.isGray = true;
							item2.isCleaning = false;
							if(index2 != (tomorrowAry.length - 1)) {
								tomorrowAry[index2 + 1].isCleaning = true;
							}
						}
					})
				})
			}
			tomorrowAry.forEach((item1, index1) => {
				if(index1 == 0 && this.colorAry[47].timeEVal != 24) {//当首日的最后一个时间的结束时间不为24:00时，更改次日的第一个时间的开始时间
					let isB1EVal = this.colorAry[47].timeEVal - 24;
					item1.timeBVal = item1.timeBVal + isB1EVal;
					item1.timeBText = ((Math.trunc(isB1EVal) < 10 ? '0' + Math.trunc(isB1EVal) : Math.trunc(isB1EVal)) + ':' + ((Math.round((isB1EVal - Math.trunc(isB1EVal)) * 60)*100/100) < 10 ? '0' + (Math.round((isB1EVal - Math.trunc(isB1EVal)) * 60)*100/100) : (Math.round((isB1EVal - Math.trunc(isB1EVal)) * 60)*100/100)));
				}
				this.timeSlotAry.push({
					nextDay: true,
					slotBText: item1.timeBText,
					slotEText: item1.timeEText,
					slotBefore: item1.isBefore,
					slotCheck: false,
					slotBVal: item1.timeBVal,
					slotEVal: item1.timeEVal,
					slotGray: item1.isGray,
					slotCleaning: item1.isCleaning,
					slotYTD: dateTwo,
					slotStatus: item1.make_status
				});
			});
		},
		closeAdvanceBooking() {
			this.$emit('closeAdvanceBooking')
		},
		appointmentSwitch(index) {
			if(this.appointmentDay != index) {
				this.appointmentDay = index;
				this.dateVal1 = this.appointmentAry[index].specificNum;
				this.getData0();
			}
		},
		cliSlotBtn(indexNow, slotCheck, slotGray, slotCleaning) {
			if(slotGray || slotCleaning) return;
			if(slotCheck == true) {
				this.timeSlotAry.forEach((item1, index1) => {
					if(item1.slotCheck == true) {
						if(index1 >= indexNow) item1.slotCheck = false;
					}
				})
			}else {//执行选中
				let indexFirst = '',//之前已有选中的第一个的索引 或 这次点击选中的时间框的索引
					checkQuantity = [];//
				try {
					this.timeSlotAry.forEach((item1, index1) => {
						if(item1.slotCheck == true) {//之前已有选中的时间框
							if(indexFirst === '') indexFirst = index1;
							if(index1 > indexNow) {
								item1.slotCheck = false;
							}else {
								checkQuantity.push({//之前已有选中的小于等于当前点击的时间框
									slotBVal: (item1.nextDay ? (item1.slotBVal + 24) : item1.slotBVal),
									slotEVal: item1.nextDay ? (item1.slotEVal + 24) : item1.slotEVal
								});
							}
						}else {//之前没有选中的时间框
							if(indexFirst !== '') {//前面有时间框被选中了
								if(indexFirst < index1 && index1 <= indexNow) {//第一个被选中到当前点击的时间框
									if(item1.slotGray == true || item1.slotCleaning == true) {
										uni.showToast({
											title: `中间时间段已有预订，选择时间必须连续`,
											icon: 'none', duration: 3000
										})
										throw new Error('aaa');
									}else {
										//1.之前没有选中的时间框 
										//2.当前的更前面有时间框被选中了 
										//3.第一个被选中到当前点击的时间框
										// console.log('+22+', checkQuantity[0])
										if(((item1.nextDay ? item1.slotEVal + 24 : item1.slotEVal) - checkQuantity[0].slotBVal) > 24) {
											uni.showToast({
												title: '单次预订最多24小时',
												icon: 'none', duration: 3000
											})
											throw new Error('aaa');
										}else {
											checkQuantity.push({
												slotBVal: (item1.nextDay ? (item1.slotBVal + 24) : item1.slotBVal),
												slotEVal: item1.nextDay ? (item1.slotEVal + 24) : item1.slotEVal
											});
											item1.slotCheck = true;
										}
									}
								}
							}else {//前面的时间框都没有被选中
								if(index1 == indexNow) {
									indexFirst = index1;
									item1.slotCheck = true;
								}
							}
						}
					})
				} catch(eee) {
					// if(eee.message!="aaa") throw eee;
				}
			}
		},
		cliAppointmentTime1() {
			let checkAry = [],
				start_time = '',
				end_time = '',
				transDaySta = false,//true表示跨天
				transDayVal = '',
				orderHour = '';
			this.timeSlotAry.forEach((item1, index1) => {
				if(item1.slotCheck) {
					if(transDayVal === '') {
						transDayVal = item1.nextDay;
					}else {
						if(transDayVal != item1.nextDay) transDaySta = true;
					}
					checkAry.push(item1);
				}
			})
			if(checkAry.length == 0) { return uni.showToast({ title: '请选择预订时间', icon: 'none' }) }
			// console.log('checkAry', checkAry)
			// console.log('transDaySta', transDaySta)
			if(transDaySta == true) {
				let oneHourVal = 0,
					twoHourVal = checkAry[checkAry.length - 1].slotEVal;
				if(checkAry[0].slotOneBefore) {
					oneHourVal = 24 - (new Date().getHours() + new Date().getMinutes() / 60);
				}else {
					oneHourVal = 24 - checkAry[0].slotBVal;
				}
				orderHour = oneHourVal + twoHourVal;
				if(orderHour < Number(this.advanceBookingObj.hour)) {
					return uni.showToast({
						title: this.advanceBookingObj.hour + '小时起订', icon: 'none', duration: 3000
					})
				}
			}else {
				let begHourVal = 0;
				if(checkAry[0].slotOneBefore) {
					begHourVal =  new Date().getHours() + new Date().getMinutes() / 60;
				}else {
					begHourVal = checkAry[0].slotBVal;
				}
				orderHour = checkAry[checkAry.length - 1].slotEVal - begHourVal;
				if(orderHour < Number(this.advanceBookingObj.hour)) {
					return uni.showToast({
						title: this.advanceBookingObj.hour + '小时起订', icon: 'none', duration: 3000
					})
				}
			}
			if(this.advanceBookingObj.setMealType == '1' && this.advanceBookingObj.setMealId == '') {
				return uni.showToast({
					title: '必购套餐，请选择套餐',
					icon: 'none', duration: 3000
				})
			}
			start_time = checkAry[0].slotYTD + ' ' + (checkAry[0].slotOneBefore ? ((new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()) + ':' + (new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes())) : checkAry[0].slotBText);
			end_time = checkAry[checkAry.length - 1].slotYTD + ' ' + checkAry[checkAry.length - 1].slotEText;
			let item = {
				tid: this.advanceBookingObj.tid,
				rid: this.advanceBookingObj.rid,
				start_time,
				end_time,
				hourVal: orderHour,
				setMealId: this.advanceBookingObj.setMealId,
				setMealMoney: this.advanceBookingObj.setMealMoney,
				order_type: (checkAry[0].slotOneBefore ? 2 : 1)
			}
			console.log('需要的参数', item)
			uni.navigateTo({
				url: '/pages/index/orderSettlement?item=' + JSON.stringify(item)
			})
			return;
			uni.showActionSheet({
				itemList: ['余额支付', '微信支付'],
				success:res1 => {
					getMemberCardruleInfo({
						token: uni.getStorageSync('token')
					}).then(res2 => {
						if(res1.tapIndex == 0) {
							let orderMoney = 0;
							if(res2.data && res2.data.type == 1) {
								orderMoney = Math.round((Math.round((orderHour) * 100) / 100 * Number(this.advanceBookingObj.originalCost) * Number(this.advanceBookingObj.cardDiscount)) * 100) / 100 + Number(this.advanceBookingObj.setMealMoney);
							}else {
								orderMoney = Math.round((Math.round((orderHour) * 100) / 100 * Number(this.advanceBookingObj.originalCost)) * 100) / 100 + Number(this.advanceBookingObj.setMealMoney);
							}
							uni.showModal({
								title: '提示', content: `确定余额支付${orderMoney}元？`, confirmColor: '#99c043',
								success:res3 => {
									if (res3.confirm) {
										this.cliAppointmentTime2(1, start_time, end_time, checkAry[0].slotOneBefore, (res2.data && res2.data.type == 1 ? res2.data.id : ''));
									}
								}
							})
						}else if(res1.tapIndex == 1) {
							this.cliAppointmentTime2(2, start_time, end_time, checkAry[0].slotOneBefore, (res2.data && res2.data.type == 1 ? res2.data.id : ''));
						}
					})
				}
			})
		},
		cliAppointmentTime2(payType, start_time, end_time, slotOneBefore, card_id) {
			unifiedOrder({
				token: uni.getStorageSync('token'),
				tid: this.advanceBookingObj.tid,
				rid: this.advanceBookingObj.rid,
				payType,
				start_time,
				end_time,
				order_type: (slotOneBefore ? 2 : 1),
				order_status: 1,
				sid: this.advanceBookingObj.setMealId,
				card_id
			}).then(res2 => {
				if(payType == 1) {
					let title = '',
						content = '';
					if(res2.code == '000000') {
						title = '预订成功';
						content = '订单号：' + res2.data.out_trade_no;
						this.cliAppointmentTime3(title, content);
						this.cliAppointmentTime4();
					}else {
						title = '预订失败';
						if(res2.code == '900001' || res2.code == '900002') {
							if(res2.code == '900001') content = '未查询到该店铺余额信息';
							if(res2.code == '900002') content = '余额支付余额不足';
							uni.showModal({
								title, content, cancelText: '我知道了',
								confirmText: '去充值', confirmColor: '#99c043',
								success:res3 => {
									if (res3.confirm) {
										uni.navigateTo({ url: '/pages/index/recharge' })
									} else if (res3.cancel) {
										this.closeAdvanceBooking();
									}
								}
							})
						} else {
							content = res2.message;
							this.cliAppointmentTime3(title, content);
						}
					}
				}else if(payType == 2) {
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: res2.data.timeStamp,
						nonceStr: res2.data.nonceStr,
						package: res2.data.package,
						signType: res2.data.signType,
						paySign: res2.data.paySign,
						success:res3 => {
							console.log('支付成功', res3);
							this.cliAppointmentTime3('预订成功', '支付成功');
							this.cliAppointmentTime4();
						}, fail:err3 => {
							console.log('支付失败-err3', err3);
							this.cliAppointmentTime3('预订失败', '您已取消支付');
						}
					})
				}
			})
		},
		cliAppointmentTime3(title, content) {
			uni.showModal({
				title, content, confirmColor: '#99c043', showCancel: false, confirmText: '我知道了',
				success:res1 => {
					if (res1.confirm) {
						// this.subscribeFun();
						this.closeAdvanceBooking();
						if(this.advanceBookingObj.topIsWho == 2) this.renovateColor();
					}
				}
			})
		},
		cliAppointmentTime4() {
			getTaeRoomDataInfo({
				tid: this.advanceBookingObj.tid,
				rid: this.advanceBookingObj.rid
			}).then(res => {
				let historyRoomList = uni.getStorageSync('historyRoomList');
				if(historyRoomList == '') historyRoomList = [];
				historyRoomList.push(res.data);
				uni.setStorageSync('historyRoomList', historyRoomList);
				// console.log(22, historyRoomList);
			})
		},
		renovateColor() {
			this.dateVal1 = dateLimit();
			this.appointmentDay = 0;
			this.getData0();
		},
		subscribeFun() {
			// uni.requestSubscribeMessage({
			//   tmplIds: [
			// 	  'yQ8VFslxofDFsztSLAEAhz1by8KftlqXeewH6a7ENbE',//订单付款通知
			// 	  '3A5LLFNlLOI8FmuQg1VoTSQ2Z-sgMbdhENmlyfd15FM',//服务完成通知
			// 	  'B8AviMN-18noH7ULHMevdxfu08liKx9vjG16v-LJHEE'//订单即将到期提醒
			//   ],
			//   success:res1 => {
			// 	  console.log('res1', res1)
			// 	  // {
			// 		 //  EbBMjRz1108yYoetYXr8bF22iu6T_RzFEk91VuWNql8: "accept",
			// 		 //  errMsg: "requestSubscribeMessage:ok"
			// 	  // }
			//   }, fail:err1 => {
			// 	  console.log('err1', err1)
			//   }
			// })
			uni.showModal({
				title: '提示', content: '是否立即跳转订单列表一键使用？', confirmColor: '#99c043',
				success:res1 => {
					if (res1.confirm) {
						uni.switchTab({ url: '/pages/order/index' })
					}
				}
			})
		}
	}
}
</script>
<style>
</style>